package day18.Exer;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

public class weatherClient {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        Socket socket=null;
        try {
            socket=new Socket("localhost",8888);
            PrintWriter pw=new PrintWriter(socket.getOutputStream(),true);
            BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream()));
            while (true) {
                System.out.println("请输入您要查询的内容");
                String str=in.next();
                if(str.equals("exit")){
                    socket.close();
                    return;
                }
                pw.println(str);
                pw.flush();
                String msg=br.readLine();
                System.out.println(msg);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
